$(function(){
	jQuery.validator.addMethod("mobile", function(value, element) {
		var reg = /^(13\d|145|147|15[0-3]|15[5-9]|177|18[0-3]|18[5-9])\d{8}$/;
	    return this.optional(element) || value=='' || reg.test(value);       
	 }, '手机号码格式不正确'); 
	jQuery.validator.addMethod("telephone", function(value, element) {
		var reg = /^(0\d{2,3}-)?([2-9]\d{6,7})+(-\d{1,4})?$/;
	    return this.optional(element) || value=='' || reg.test(value);       
	 }, '电话号码格式不正确'); 
	jQuery.validator.addMethod("postCode", function(value, element) {
		var reg = /^[1-9]\d{5}$/;
	    return this.optional(element) || reg.test(value);       
	 }, '邮政编码格式不正确');  
	jQuery.validator.addMethod("idcard", function(value, element) {
		var reg1 = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
		var reg2 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
	    return this.optional(element) || value=='' || reg1.test(value) || reg2.test(value);       
	 }, '身份证格式不正确');   
	jQuery.validator.addMethod("mobileOrTelephone", function(value, element) {
		var reg1 = /^(13\d|145|147|15[0-3]|15[5-9]|177|18[0-3]|18[5-9])\d{8}$/;
		var reg2 = /^(0\d{2,3}-)?([2-9]\d{6,7})+(-\d{1,4})?$/;
	    return this.optional(element) || value=='' || reg1.test(value) || reg2.test(value);       
	 }, '联系方式格式不正确');   
	jQuery.validator.addMethod("username", function(value, element) {
		var flag = /^[a-zA-Z]+$/.test(value);
		flag = flag || /^\d+$/.test(value);
		flag = flag || /^-+$/.test(value);
		flag = flag || /^_+$/.test(value);
	    return this.optional(element) || (!flag && /^[a-zA-Z0-9_-]{5,25}$/.test(value));       
	 }, '用户名格式不正确');   
});